class User < ActiveRecord::Base
  has_secure_password

  validates :password, length: { minimum: 6 }, if: :password_validation_required?

  def password_validation_required?
    # password_digest.blank? || password.present?
    password.present? || password_confirmation.present?
  end

  def admin?
    self.user_type == USER_TYPE["后台管理员"]
  end
end